/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.sysschool.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.sysschool.entity.SysSchool;
import com.thinkgem.jeesite.modules.sys.service.OfficeService;
import com.thinkgem.jeesite.modules.sysschool.dao.SysSchoolDao;

/**
 * 学校管理Service
 * @author lihuan
 * @version 2018-11-28
 */
@Service
@Transactional(readOnly = true)
public class SysSchoolService extends CrudService<SysSchoolDao, SysSchool> {

	@Autowired
	OfficeService officeService;
	
	public SysSchool get(String id) {
		return super.get(id);
	}
	
	public List<SysSchool> findList(SysSchool sysSchool) {
		return super.findList(sysSchool);
	}
	
	public Page<SysSchool> findPage(Page<SysSchool> page, SysSchool sysSchool) {
		return super.findPage(page, sysSchool);
	}
	
	@Transactional(readOnly = false)
	public void save(SysSchool sysSchool) {
		super.save(sysSchool);
	}
	
	@Transactional(readOnly = false)
	public void delete(SysSchool sysSchool) {
		super.delete(sysSchool);
	}

	public SysSchool findByCode(String id) {
		return dao.findByCode(id);
	}
	
	/**
	 * @author lihuan
	 * @date 2018年12月17日
	 * @description 学校编码
	 */
	public String getSchCode(SysSchool school) {
		String schCode="";
		int count;
		count=dao.getCount(school)+1;
		schCode+=school.getParentCode() +"_"+ String.format("%02d", count);
		return schCode;
	}

	
}